package com.imessage.type;


import com.fasterxml.jackson.annotation.JsonValue;
import io.ebean.annotation.DbEnumValue;

import java.util.Objects;

public enum DeviceClientState implements EnumMessage{

    run("1", "运行","",""),
    shutdown("2", "关机","",""),
    pause("3", "暂停","","");

    String code;
    String display;
    String name;
    String value;

    private DeviceClientState(String code, String display, String name, String value) {
        this.code = code;
        this.display = display;
        this.name=name;
        this.value=value;
    }

    //获取枚举实例
    public static DeviceClientState fromValue(String code) {
        for (DeviceClientState statusEnum : DeviceClientState.values()) {
            if (Objects.equals(code, statusEnum.getCode())) {
                return statusEnum;
            }
        }
        throw new IllegalArgumentException();
    }

    //获取枚举实例
    public static DeviceClientState toValue(String display) {
        for (DeviceClientState statusEnum : DeviceClientState.values()) {
            if (Objects.equals(display, statusEnum.getDisplay())) {
                return statusEnum;
            }
        }
        return DeviceClientState.shutdown;
    }

    @DbEnumValue
    @Override
    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    @JsonValue
    public String getDisplay() {
        return display;
    }

    public void setDisplay(String display) {
        this.display = display;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return display;
    }
}
